"""
登录密码错误测试
"""
import pytest
from Config.Base import Base
from playwright.sync_api import Page, expect, Playwright
import allure
from Config.config import *
from Config.URL import *
import os


@pytest.mark.基础管理系统
@pytest.mark.登录
def test_case(playwright : Playwright) -> None:
    # headless=False
    SetupTeardown = Base(playwright)
    SetupTeardown.goto(url)
    SetupTeardown.login(username_admin, "123456")
    page = SetupTeardown.page

    # 断言
    expect(page.get_by_text("用户1名或密码不正确")).to_be_visible()
    # 测试结果截图
    filename = os.path.join(test_screenshot_dir, f"{'用户名或密码不正确'}.png")
    page.screenshot(path=filename)
    allure.attach.file(source=filename, name='用户名或密码不正确',
                       attachment_type=allure.attachment_type.PNG)

    SetupTeardown.close()
